package basic.courseLearn09.problem;

import org.junit.Test;

import java.util.ArrayList;
import java.util.List;

//打印字符串子序列问题，连续不连续皆可
public class PrintSubstring {

    public List<String> results = new ArrayList<>();

    /**
     * 打印字符串子序列, 连续不连续皆可
     * @param str 字符串
     * @param i 起始位置
     * @param result 结果字符串
     */
    public void solution_1(String str,int i,String result) {
        if(i==str.length()){
            results.add(result);
            return;
        }
        //加上第i个字符
        String newResult = result + str.charAt(i);
        solution_1(str,i+1,newResult);

        //不加第i个字符
        solution_1(str,i+1,result);

    }

    @Test
    public void test_solution_1() {
        String str = "abc";
        solution_1(str,0,"");
        System.out.println(results);
    }

}
